package com.people.core.validator.annotation;

import com.people.core.validator.valid.CompareValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 零值检验
 * @author zhenglin
 * @date 2022/4/13
 */
@Documented
@Constraint(validatedBy = CompareValidator.class)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface CompareValid {
    /**
     * 消息
     *
     * @return {@link String}
     */
    String message() default "参数值非法";

    /**
     * value
     *
     * @return long
     */
    long value() default 0L;

    /**
     * 比较表达式
     *
     * @return {@link Compare}
     */
    Compare compare() default Compare.EQ;

    Class[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    enum Compare {
        /**
         * 大于等于
         */
        GTE,
        /**
         * 大于
         */
        GT,
        /**
         * 小于等于
         */
        LTE,
        /**
         * 小于
         */
        LT,
        /**
         * 等于
         */
        EQ
    }
}
